<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function load(src, resolve) {
      let script = document.createElement('script');
      script.src = src;
      script.onload = resolve;
      document.body.appendChild(script)
    }
    /*
    这两个函数在任务队列中执行，先进先出 不是test01一定先执行，所以test02依赖test01，有时会报错！
    load('./js/01-test.js', () => {
      test01();
    })

    load('./js/02-test.js', () => {
      test02();
    })
    */

    load('./js/01-test.js', () => {
      test01();
      load('./js/02-test.js', () => {
        test02();
      })
    })

    console.log('主线程')
  </script>
</body>
</html>